package com.jeff.tianti.cms.dao;

import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jeff.tianti.cms.entity.Message;
import com.jeff.tianti.cms.dto.MessageQueryDTO;

/**
 * @author liuyi
 * @desc MessageDaoImpl类
 * @date 2019-06-21
 */

public class MessageDaoImpl extends CustomBaseSqlDaoImpl implements MessageDaoCustom {

    public PageModel<Message> queryMessagePage(MessageQueryDTO messageQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from Message t ");
        hql.append(" order by t.createDate desc ");

        return this.queryForPageWithParams(hql.toString(), map, messageQueryDTO.getCurrentPage(), messageQueryDTO.getPageSize());
    }

    public List<Message> queryMessageList(MessageQueryDTO messageQueryDTO) {
        Map<String, Object> map = new HashMap<String, Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from Message t ");
        return this.queryByMapParams(hql.toString(), map);
    }


}